package com.woniu.exception;

import com.woniu.utils.ResData;
import feign.FeignException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(FeignException.class)
    public ResData handleFeignException(FeignException e) {
        return ResData.failed(e.status(), e.getMessage());

    }


    @ExceptionHandler(PasswordException.class)
    public ResData handleFeignException(PasswordException e) {
        return ResData.failed(1001, "用户名或密码错误");
    }

    @ExceptionHandler(IDDuplicateException.class)
    public ResData handleFeignException(IDDuplicateException e) {
        return ResData.failed(1002, "ID重复，请重新输入");
    }

}
